/**
 * Created by Administrator on 2019/5/17.
 */
var year=prompt("请输入年份");
var month=prompt("请输入月份");

year=Number(year);
month=Number(month);

var days=0;
function ruNian(y){
    if(y%400===0 || (y%4===0 && y%100!==0)){
        return true;
    }else {
        return false;
    }
}



for (var i=1980;i<year;i++){
    if(ruNian(i)){
        days+=366;
    }else {
        days+=365;
    }
    console.log(ruNian(i));
}

console.log(days);

for (var j=1;j<month;j++){
    switch (j){
        case 1:
            days+=31;
            break;
        case 2:
            if (ruNian(year)){
                days+=29;
            }else {
                days+=28;
            }
            break;
        case 3:
            days+=31;
            break;
        case 4:
            days+=30;
            break;
        case 5:
            days+=31;
            break;
        case 6:
            days+=30;
            break;
        case 7:
            days+=31;
            break;
        case 8:
            days+=31;
            break;
        case 9:
            days+=30;
            break;
        case 10:
            days+=31;
            break;
        case 11:
            days+=30;
            break;
        case 12:
            days+=31;
            break;
    }
}
console.log(days);

days+=2;

var yu=days%7;
console.log(yu);

var shu=0
switch (month){
    case 1:
        shu+=31;
        break;
    case 2:
        if (ruNian(year)){
            shu+=29;
        }else {
            shu+=28;
        }
        break;
    case 3:
        shu+=31;
        break;
    case 4:
        shu+=30;
        break;
    case 5:
        shu+=31;
        break;
    case 6:
        shu+=30;
        break;
    case 7:
        shu+=31;
        break;
    case 8:
        shu+=31;
        break;
    case 9:
        shu+=30;
        break;
    case 10:
        shu+=31;
        break;
    case 11:
        shu+=30;
        break;
    case 12:
        shu+=31;
        break;
}




var lost=0
switch (month-1){
    case 1:
        lost+=31;
        break;
    case 2:
        if (ruNian(year)){
            lost+=29;
        }else {
            lost+=28;
        }
        break;
    case 3:
        lost+=31;
        break;
    case 4:
        lost+=30;
        break;
    case 5:
        lost+=31;
        break;
    case 6:
        lost+=30;
        break;
    case 7:
        lost+=31;
        break;
    case 8:
        lost+=31;
        break;
    case 9:
        lost+=30;
        break;
    case 10:
        lost+=31;
        break;
    case 11:
        lost+=30;
        break;
    case 0:
        lost+=31;
        break;
}






var next=42-shu-yu;


var day=document.querySelector(".day");
for (var k=lost-yu+1;k<=lost;k++){
    day.innerHTML+="<span class='h'>"+k+"</span>"
}

var d=new Date().getDate();

for(var s=1;s<=shu;s++){
    if(s==d){
        day.innerHTML += '<span class="today">'+s+'</span>'
}else{
    day.innerHTML += '<span>'+s+'</span>'
}
}



for  (var m=1;m<=next;m++){
    day.innerHTML+="<span class='h'>"+m+"</span>"
}


document.querySelector(".nian").innerHTML=year;
document.querySelector(".yue").innerHTML=month;
